package edu.spec.student.model.questionnaire;

import edu.spec.student.model.Student;
import edu.spec.basic.model.enumeration.FinishStatus;

import javax.persistence.*;
import java.util.Date;

/**
 * "学生"和"问卷调查"的关联表
 * 在创建问卷调查以后，勾选相应的班级后，对该班级的全体学生创建"学生--问卷调查" 记录
 * 学生通过该表查询自己的对于的" 问卷调查"
 */
@Entity
@Table(name = "t_student_questionnaire")
public class StudentQuestionnaire {
    /**
     * 主键
     */
    private Integer id;
    /**
     * 关联的"学生" 对象
     */
    private Student student;
    /**
     * 关联的"问卷调查" 对象
     */
    private Questionnaire questionnaire;
    /**
     * 完成状态，初始值为"未完成"，学生完成以后就是"已完成"
     */
    private FinishStatus finishStatus;
    /**
     * 完成日期，学生完成提交"问卷调查"的时间
     */
    private Date finishDate;

    public StudentQuestionnaire() {
    }

    public StudentQuestionnaire(Student student, Questionnaire questionnaire, FinishStatus finishStatus, Date finishDate) {
        this.student = student;
        this.questionnaire = questionnaire;
        this.finishStatus = finishStatus;
        this.finishDate = finishDate;
    }

    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "student_id")
    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @ManyToOne
    @JoinColumn(name = "questionnaire_id")
    public Questionnaire getQuestionnaire() {
        return questionnaire;
    }

    public void setQuestionnaire(Questionnaire questionnaire) {
        this.questionnaire = questionnaire;
    }

    @Column(name = "finish_status")
    public FinishStatus getFinishStatus() {
        return finishStatus;
    }

    public void setFinishStatus(FinishStatus finishStatus) {
        this.finishStatus = finishStatus;
    }

    @Column(name = "finish_date")
    public Date getFinishDate() {
        return finishDate;
    }

    public void setFinishDate(Date finishDate) {
        this.finishDate = finishDate;
    }
}
